//
//  GameViewController.m
//  A_GOGO
//
//  Created by Liuiu on 16/1/15.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "GameViewController.h"
#import "GameTableViewCell.h"
#import "HomeModel.h"
#import "SecondView.h"

#import <UIViewController+MMDrawerController.h>
#import <MMDrawerBarButtonItem.h>
#import "LeftDrawerViewController.h"
@interface GameViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, retain)UITableView *tableView;//该页面的tableView
@property (nonatomic, retain)UICollectionView *collection;
@property (nonatomic ,retain)UITableView *usualTabelView;//第二页面的tableview
@property (nonatomic ,retain)UIView *usualView;//第二view

@end

@implementation GameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    //创建两个Segment 来实现两个界面相互跳转
    UISegmentedControl *seg =[[UISegmentedControl alloc]initWithItems:@[@"游戏圈",@"圈子动态"]];
    seg.frame = CGRectMake(100, 100, 160, 35);
    
    //设置默认选中
    seg.selectedSegmentIndex = 0;
    [seg addTarget:self action:@selector(seg:) forControlEvents:UIControlEventValueChanged];
    //添加到导航栏中间
    self.navigationItem.titleView = seg;
    [seg release];
    
    //个人资料
    UIButton *buttona = [UIButton buttonWithType:UIButtonTypeSystem];
    buttona.backgroundColor = [UIColor whiteColor];
    buttona.frame =  CGRectMake(0, 0, 38, 38);
    buttona.layer.cornerRadius = 19;
    [buttona setBackgroundImage:[UIImage imageNamed:@"personal"] forState:UIControlStateNormal];
    [buttona addTarget:self action:@selector(left:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:buttona];

    //添加
    UIBarButtonItem *item =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"add"] style:UIBarButtonItemStylePlain target:self action:@selector(right:)];
    self.navigationItem.rightBarButtonItems = @[item];
//******** usualView用来铺设论坛的tableview
    self.usualView = [[UIView alloc]initWithFrame:self.view.frame];
    _usualView.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:_usualView];
    [_usualView release];
    
    //初始化一个view放在usualView上 用来创建tableview
    SecondView *usualTableView =[[SecondView alloc] initWithFrame:self.view.bounds];
    [self.usualView addSubview:usualTableView];
    [usualTableView release];
    
    
//********  tableView
    self.tableView =[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    _tableView.backgroundColor =[UIColor whiteColor];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView release];
    
    //注册重用池
    [_tableView registerClass:[GameTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    [self data];
    
    
}
- (void)data
{
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    GameTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor greenColor];
    return cell;
}

- (void)seg:(UISegmentedControl *)seg
{
    if (seg.selectedSegmentIndex == 0) {
        self.tableView.hidden = NO;
    }if (seg.selectedSegmentIndex == 1) {
        self.tableView.hidden = YES;
    }
}

- (void)left:(UIButton *)btn
{
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:^(BOOL finished) {
        
    }];
}
- (void)right:(UIBarButtonItem *)btn
{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
